package org.mxp.runner;

import lombok.extern.slf4j.Slf4j;
import org.mxp.service.TableMessageService;
import org.mxp.utils.TableMessageUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import org.apache.commons.collections.MapUtils;

import java.util.Map;

@Slf4j
@Component
public class InitApplicationRunner implements ApplicationRunner {
    @Autowired
    private TableMessageService tableMessageService;
    @Autowired
    private TableMessageUtil tableMessageUtil;
    @Override
    public void run(ApplicationArguments args) throws Exception {
        log.info("初始化方法执行...");
        Map<String, Object> info = tableMessageService.lastInfo();
        tableMessageUtil.initAllCell(MapUtils.getString(info, "data"));
    }
}
